<?php
namespace app\hhc\controller;

use app\common\controller\Frontend;
use think\Controller;
use think\Request;
use think\Db;
use think\Cache;
use think\Config;
//use think\Db;

/**
 * 前端基础控制器
 *
 * @icon fa fa-circle-o
 */
class Base extends Frontend
{
    protected $model = null;

    public function _initialize()
    {
		if(Cache::get('cache') == false){
			$category = Db::name('category')->select();
			$cache['category'] = $category;
			$cache['site'] = Config::get("site");
			Cache::set('cache',$cache);
		}
		
		$this->cache = Cache::get('cache');
		$this->module = Request::instance()->module();
		$this->assign('module',$this->module);
		$this->assign('cache',Cache::get('cache'));
		$this->assign('color1','#5EB04A');
		$this->assign('color2','#FF9900');
		
		//载入黄花菜分类
		$cache = Cache::get('cache');
		$list = array();
		foreach($cache['category'] as $i => $son){
			if($son['type'] == 'hhc')
			$list[] = $son;
		}
		$this->category = $list;
		$this->sitename = '中国黄花菜';
		$this->assign('category_hhc',$list);
		
		//载入黄花菜广告
		$one_ad = Db::name('slider')->cache(true)->find(4);
		//dump($one_ad);die;
		//$this->ad1 = $one_ad;
		$this->assign('ad1',$one_ad);
		
		$site = Config::get("site");
        parent::_initialize();
    }
	
	/*
	public function _initialize()
    {
		if(Cache::get('cache') == false){
		    $one = Db::name('configvalue')->where('id','config')->find();
			$category = Db::name('category')->select();
			$cache['config'] = json_decode($one['content'],true);
			$cache['category'] = $category;
			Cache::set('cache.config',$cache['config']);
			Cache::set('cache.category',$cache['category']);
		}
		
		$this->assign('cache',Cache::get('cache'));
		$this->assign('color1','#5EB04A');
		$this->assign('color2','#FF9900');
        parent::_initialize();
    }
	
	*/
	
}
